const express = require('express')
const app = new express();

const setServer = (req,res,next)=>{
    //const now = new Date();

    const server ={
        name:'test',
        port:3000
    }

    //req.server="this is now";
    req.server= server;
    next()
}

app.use(setServer) // 注册中间件

// app.listen('/list',(req,res)=>{
//     res.json(req.server)
// })

app.get('/login',(req,res)=>{
    res.json(req.server)
})

const server = app.listen(3000,'localhost',(req,res)=>{
    const address = server.address();
    console.log(" This is http://%s:%s",address.address,address.port)
})
